package com.gainloop.Listeners;

import java.util.LinkedList;

import com.gainloop.Adapters.TagAdapter;

import android.view.View;
import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;

public class AutoCompListener implements AdapterView.OnItemClickListener{
	
	TagAdapter _listAdapter;
	AutoCompleteTextView _tagsRow;
	LinkedList<String> _currentAddedTags;

	public AutoCompListener(LinkedList<String> currentAddedTags, TagAdapter listAdapter, AutoCompleteTextView tagsRow){
		_listAdapter = listAdapter;
		_currentAddedTags = currentAddedTags;
		_tagsRow = tagsRow;
		
	}
	
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		_currentAddedTags.addLast((String)parent.getAdapter().getItem(position));
		_listAdapter.notifyDataSetChanged();
		_tagsRow.setText("");
	}

}
